<template>
  <div>
    <table>
      <tr>
        <td>名称</td>
      </tr>
      <tr v-for="i in teas">
        <td>{{ i.name }}</td>
      </tr>

    </table>

    <p>名称：<input type="text" v-model="form.name"></p>
    <p>账号：<input type="text" v-model="form.username"></p>
    <p>密码：<input type="text" v-model="form.password"></p>
    <button @click="regi">注册</button>
    <router-link :to="{name:'tea_login'}">登录</router-link>

  </div>
</template>

<script>
export default {
  name: "tea_regi",
  data() {
    return {
      form: {},
      teas: []
    }
  },
  methods: {
    regi() {
      this.$axios.post('users/tea/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('注册成功')
            this.form = {}
            this.get_tea()
          }

        })
    },
    get_tea() {
      this.$axios.get('users/tea/')
        .then(res => {
          this.teas = res.data.list
        })
    }
  },
  mounted() {
    this.get_tea()
  }
}
</script>

<style scoped>

</style>
